package com.wangxiang.sys.manage.controller;
import com.alibaba.fastjson.JSONObject;
import com.wangxiang.common.utils.R;
import com.wangxiang.sys.manage.entity.MenuListEntity;
import com.wangxiang.sys.manage.service.MenuListService;
import com.wangxiang.sys.manage.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("sys/menu")
public class SysMenuController{
    @Resource
    private MenuListService menuListService;
    @Autowired
    RedisUtils redisUtils;

    /**
     * 根据角色生成菜单
     * @return
     */
    @GetMapping("/nav")
    public R getMenu(){

        int roleId = (int) redisUtils.get("roleId");

        List<MenuListEntity> menuList = menuListService.getMenuList(roleId);

        return R.ok().put("data",menuList);

    }
    /**
     * 查看所有菜单
     */
    @RequestMapping("/getallmenu")
    public R getAllMenu(){
        List<MenuListEntity> allMenu = menuListService.getAllMenu();
        return R.ok().put("data",allMenu);
    }

}
